#
#	genx_html.py
#
#	David Janes
#	2008.08.16
#
#	GenX - search, create and insert structured data
#

import sys
import sets
import types
import re
import pprint
import cgi
import md5
import imp
import os
import os.path
import traceback

import genx_cfg
import bm_extract

class HTMLMixin:
	def __init__(self):
		pass

	def StandardHeader(self, stylesheets = None, **ad):
		if not stylesheets:
			stylesheets = []

		stylesheets.append("http://yui.yahooapis.com/2.5.2/build/reset/reset-min.css")
		stylesheets.append("resources/css.css")
			
		results = []
		results.append("""\
<html>
<head>
""")
		for stylesheet in stylesheets:
			results.append("""<link rel="stylesheet" type="text/css" href="%s">""" % stylesheet)

		results.append("""\
<title>%(title)s</title>
</head>
<body>
""" % ad)

		return	"\n".join(results)

	def StandardFooter(self):
		gtracker = bm_extract.extract(genx_cfg.cfg, "google_analytics.tracker")
		if gtracker: 
			return	"""
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%%3E%%3C/script%%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("%s");
pageTracker._trackPageview();
</script>
</body>
</html>
""" % gtracker

		return	"""\
</body>
</html>
"""
